﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using shop.Utils;

namespace shop.Modules
{
    public partial class ho8 : System.Web.UI.UserControl
    {
        private static int masterID = 1;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                SqlConnection conn = DB.createSqlConnection();
                conn.Open();
                SqlCommand cmd = new SqlCommand("select votetype from votemaster where masterid= " + masterID, conn);
                this.show.Text = cmd.ExecuteScalar().ToString();


                cmd = new SqlCommand("select * from voteitems where masterid = " + masterID, conn);
                SqlDataReader odr = cmd.ExecuteReader();
                this.rblItemList.DataSource = odr;
                this.rblItemList.DataTextField = "voteitem";
                this.rblItemList.DataValueField = "itemid";
                this.rblItemList.DataBind();
                odr.Close();
                conn.Close();
            }

        }

        protected void btSubmit_Click(object sender, EventArgs e)
        {
            string sqlString = "update voteitems set itemNumber =itemNumber +1 where masterid = " + masterID + " and itemid = " + this.rblItemList.SelectedValue.ToString();
            DB.executeSQL(sqlString);
        }
    }
}